﻿using System;
using System.Collections.Generic;
using System.Management.Automation;
using Microsoft.SharePoint;
using Microsoft.SharePoint.PowerShell;
using Microsoft.SharePoint.Administration;
using System.Globalization;
using System.ComponentModel;
using System.Security.Principal;
using System.Collections.Specialized;
using System.Linq;
using Microsoft.SharePoint.Utilities;


namespace SlamCms.SharePoint.PowerShell
{
	[Cmdlet("Export", "SlamSite")]
	public class SpCmdletExportSlamSite : SPCmdlet
	{
        [Parameter(Mandatory = true)]
        public string SiteUrl
        {
            get;
            set;
        }

        [Parameter(Mandatory = true)]
        public string FileName
        {
            get;
            set;
        }

		[Parameter(Mandatory = false)]
		public SwitchParameter IncludeContent
		{
			get;
			set;
		}

		protected override void InternalProcessRecord()
		{
			try
			{
				Migration.MigrationService.Export(SiteUrl, FileName, true, IncludeContent.IsPresent);
			}
			catch (Exception ex)
			{
				WriteResult(ex.ToString());
			}
		}
	}
}
